package com.bluedot.bank.action;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.bluedot.bank.dao.privilege.Privilege;
import com.bluedot.bank.dao.user.User;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class CustomerFilterAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private List<Filters> filters=new ArrayList<Filters>();
	{
		filters.add(new Filters(1,"全部"));
		filters.add(new Filters(2,"ID"));
		filters.add(new Filters(3,"姓"));
		filters.add(new Filters(4,"名"));
		filters.add(new Filters(5,"中间字母"));
		filters.add(new Filters(6,"城市"));
	}
	/**
	 * @return the filters
	 */
	public List<Filters> getFilters() {
		return filters;
	}
	/**
	 * @param filters the filters to set
	 */
	public void setFilters(List<Filters> filters) {
		this.filters = filters;
	}
	@Override
	public String execute() throws Exception {
		Map session=ActionContext.getContext().getSession();
		User user=(User)session.get("user");
		Set<Privilege> set=user.getRole().getPrivileges();
		Iterator<Privilege> iterator=set.iterator();
		while(iterator.hasNext()){
			if("客户管理".equals(iterator.next().getPrivilegeName()))
				return SUCCESS;
		}
		return "noPrivilege";
	}

}

class Filters {
	private int key;
	private String name;
	public Filters(int key,String name){
		this.key=key;
		this.name=name;
	}

	/**
	 * @return the key
	 */
	public int getKey() {
		return key;
	}

	/**
	 * @param key
	 *            the key to set
	 */
	public void setKey(int key) {
		this.key = key;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
}